"use strict";
/* function identity(value: string): string;
function identity(value: number): number;
function identity(value: boolean): boolean;
function identity(value: boolean[]): boolean[];
function identity(value: number[]): number[];
function identity(value: object): object;
function identity(value: string | number | boolean | number[] | boolean[] | object) {
  return value;
}

const s = identity({ id: 1, name: 'John' });
console.log(s.name) // error */
function identity(value) {
    return value;
}
let user = {
    id: 1,
    name: "John"
};
// const s1 = identity<string>("hello")
// const s2 = identity<number>(123)
// const s3 = identity<User>(user)
// console.log(s3.name)
const s1 = identity("hello");
const s2 = identity(123);
const s3 = identity(user);
console.log(s3.name);
// 传入相同类型的两个参数，得到这个类型的数组
function getArray(a, b) {
    return [a, b];
}
const as = getArray("a", "b");
function myNumberFilter(arr, callback) {
    const result = [];
    for (let i = 0; i < arr.length; i++) {
        const item = arr[i];
        if (callback(item)) {
            result.push(item);
        }
    }
    return result;
}
const filterArr1 = myNumberFilter([1, 2, 3, 4, 5], item => item % 2 === 0);
console.log(filterArr1);
function filter(arr, callback) {
    const result = [];
    for (let i = 0; i < arr.length; i++) {
        const item = arr[i];
        if (callback(item)) {
            result.push(item);
        }
    }
    return result;
}
const filterArr2 = filter([1, 2, 3, 4, 5], item => item % 2 === 0);
console.log(filterArr2);
const filterArr3 = filter(["xxx.js", "aaa.java", "bbb.md"], item => item.endsWith(".js"));
console.log(filterArr3);
